package com.example.democlient.network.packet;

import com.example.democlient.network.ServerConnection;

import android.util.Log;


public abstract class ClientPacket extends BaseClientPacket<ServerConnection> implements Cloneable
{

	protected ClientPacket(int opcode)
	{
		super(opcode);
	}

	/**
	 * run runImpl catching and logging Throwable.
	 */
	public final void run()
	{
		try
		{
			runImpl();
		}
		catch(Throwable e)
		{
			Log.w("","error handling ls (" + getConnection().getIP() + ") message " + this, e);
		}
	}

	/**
	 * Clones this packet object.
	 * 
	 * @return CsClientPacket
	 */
	public ClientPacket clonePacket()
	{
		try
		{
			return (ClientPacket) super.clone();
		}
		catch(CloneNotSupportedException e)
		{
			return null;
		}
	}
	
}
